#!/bin/bash
#安装系统依赖项
echo "执行一键安装脚本,免配置"
echo "开始配置云崽运行环境-请耐心等待,基于环境编写，只适用于ubuntu18.04"
mv /etc/apt/sources.list /etc/apt/sources.list.bak
#配置清华源
echo "deb https://mirrors.ustc.edu.cn/ubuntu/ lunar main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src https://mirrors.ustc.edu.cn/ubuntu/ lunar main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src https://mirrors.ustc.edu.cn/ubuntu/ lunar-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src https://mirrors.ustc.edu.cn/ubuntu/ lunar-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src https://mirrors.ustc.edu.cn/ubuntu/ lunar-backports main restricted universe multiverse" >> /etc/apt/sources.list
apt update
if ! [ -x "$(command -v node)" ]; then
    echo "node 开始安装"
    apt  update
    apt install curl -y
    curl -sL https://deb.nodesource.com/setup_19.x |  bash -
    apt update
    apt -y install nodejs
fi
sudo apt install git -y
sudo apt install ffmpeg -y
sudo apt-get install libfdk-aac-dev
sudo apt-get -f install chromium-browser -y 
sudo apt-get install -y libgbm-dev
sudo apt install vim -y
sudo apt install redis -y
redis-server --save 900 1 --save 300 10 --daemonize yes
#字体
apt install -y --force-yes --no-install-recommends fonts-wqy-microhei
#依赖项
apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

if ! [ -x "$(command -v vim)" ]; then
    #vim乱码解决
    echo "set fileencodings=utf-8,gb2312,gbk,gb18030"  >> /usr/share/vim/vimrc
    echo "set termencoding=utf-8" >> /usr/share/vim/vimrc
    echo "set fileformats=unix" >> /usr/share/vim/vimrc
    echo "set encoding=prc"  >> /usr/share/vim/vimrc
fi
echo "基础运行环境配置完成，等待5s自动执行云崽安装脚本"
sleep 5
bash <(curl -sL https://gitee.com/Liplay-1/yun-zai-box/raw/master/Yunzai-Bot_install.sh )